# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libidn2
pkgver=2.3.7
pkgrel=0
pkgdesc="Encode/Decode library for internationalized domain names"
url="https://www.gnu.org/software/libidn#libidn2"
arch="all"
license="GPL-2.0-or-later OR LGPL-3.0-or-later"
makedepends="libunistring-dev"
checkdepends="diffutils"
subpackages="${pkgname#lib}-utils:utils $pkgname-static $pkgname-dev $pkgname-doc"
source="https://ftp.gnu.org/gnu/libidn/libidn2-$pkgver.tar.gz"

# secfixes:
#   2.2.0-r0:
#     - CVE-2019-12290
#   2.1.1-r0:
#     - CVE-2019-18224

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-nls
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	# only keep man pages
	rm -rf "$pkgdir"/usr/share/info
}

utils() {
	license='GPL-3.0-or-later'
	pkgdesc="$pkgdesc (CLI utilities)"

	amove 'usr/bin'
}

sha512sums="
eab5702bc0baed45492f8dde43a4d2ea3560ad80645e5f9e0cfa8d3b57bccd7fd782d04638e000ba07924a5d9f85e760095b55189188c4017b94705bef9b4a66  libidn2-2.3.7.tar.gz
"
